﻿#include <vector>
#include <stack>
using namespace std;

class Solution {
public:
    vector<int> canSeePersonsCount(vector<int>& heights) {
        int n = heights.size();
        vector<int> answer(n, 0);
        stack<int> stk;
        for (int i = n - 1; i >= 0; --i) {
            while (!stk.empty() && heights[i] > heights[stk.top()]) {
                answer[i]++;
                stk.pop();
            }
            if (!stk.empty()) {
                answer[i]++;
            }
            stk.push(i);
        }
        return answer;
    }
};
int main() {
    // 你的程序代码
    return 0;
}
